import mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.User;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Mysqltest {
    public static void main(String[] args) throws IOException {
        //加载核心配置文件，获取SqlSessionFactory工厂
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        //获取SqlSession对象
        SqlSession sqlSession = sqlSessionFactory.openSession();
//        List<Object> users = sqlSession.selectList("test.selectAll");
//        System.out.println(users);

        //获取userMapper代理对象
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        User zhangjia = mapper.select("zhangjia", "1234");
        System.out.println(zhangjia);


        sqlSession.close();
    }
}
